import request from '@/utils/request'

// 获取点位统计
export const getNodeCollect = () => {
  return request.get('/api/vm-service/node/nodeCollect')
}

// 获取点位数量
export const getNodeCount = () => {
  return request.get('/api/vm-service/node/count')
}

// 获取售货机货道详情
export const getChannelList = (innerCode) => {
  return request.get(`/api/vm-service/channel/channelList/${innerCode}`)
}

// 搜索区域列表
export const searchRegionList = (params) => {
  return request.get('/api/vm-service/region/search', {
    params
  })
}

// 新增区域
export const addRegion = (data) => {
  return request.post('/api/vm-service/region', data)
}

// 获取区域信息
export const getRegionInfo = (id) => {
  return request.get(`/api/vm-service/region/${id}`)
}

// 搜索点位
export const searchNode = (params) => {
  return request.get('/api/vm-service/node/search', {
    params
  })
}

// 更新区域信息
export const updateRegionInfo = (data) => {
  return request.put(`/api/vm-service/region/${data.id}`, data)
}

// 删除区域
export const delRegion = (id) => {
  return request.delete(`/api/vm-service/region/${id}`)
}

// 新增点位
export const addNode = (data) => {
  return request.post('/api/vm-service/node', data)
}

// 获取商圈列表
export const getBusinessList = () => {
  return request.get('/api/vm-service/businessType')
}

// 获取点位信息
export const getNodeInfo = (id) => {
  return request.get(`/api/vm-service/node/vmList/${id}`)
}

// 更新点位
export const updateNode = (data) => {
  return request.put(`/api/vm-service/node/${data.id}`, data)
}

// 删除点位
export const delNode = (id) => {
  return request.delete(`/api/vm-service/node/${id}`)
}
// 搜素设备列表
export const searchVmList = (params) => {
  return request.get('/api/vm-service/vm/search', { params })
}

// 新增设备
export const addVm = (data) => {
  return request.post('/api/vm-service/vm', data)
}

// 搜素设备类型
export const searchVmType = (params) => {
  return request.get('/api/vm-service/vmType/search', { params })
}

// 获取策略列表
export const getPolicyList = () => {
  return request.get('/api/vm-service/policy')
}

// 批量修改策略
export const applyPolicy = (data) => {
  return request.put('/api/vm-service/vm/applyPolicy', data)
}

// 获取设备策略
export const getVmPolicy = (innerCode) => {
  return request.get(`/api/vm-service/policy/vmPolicy/${innerCode}`)
}

// 修改设备点位
export const editVmNode = (data) => {
  return request.put(`/api/vm-service/vm/${data.id}/${data.nodeId}`)
}

// 获取设备货道详情
export const getChannelInfo = (innerCode) => {
  return request.get(`/api/vm-service/channel/channelList/${innerCode}`)
}

// 搜索商品列表
export const searchSku = (params) => {
  return request.get('/api/vm-service/sku/search', { params })
}

// 获取补货推荐
export const getBusinessTop10 = (businessId) => {
  return request.get(`/api/vm-service/sku/businessTop10/${businessId}`)
}

// 货道配置
export const updateChannel = (data) => {
  return request.put('/api/vm-service/channel/channelConfig', data)
}

// 搜索合作商列表
export const searchPartnerList = (params) => {
  return request.get('/api/user-service/partner/search', { params })
}

// 新增设备类型
export const addVmType = (data) => {
  return request.post('/api/vm-service/vmType', data)
}

// 图片上传
export const imgUpload = (data) => request.post('/api/vm-service/sku/fileUpload', data)

// 设备类型修改
export const updateVmType = (data) => request.put(`/api/vm-service/vmType/${data.typeId}`, data)

// 设备类型删除
export const delVmType = (typeId) => request.delete(`/api/vm-service/vmType/${typeId}`)

// 获取商品类型
export const getVmTypeList = (params) => request.get(`/api/vm-service/skuClass/search`, { params })

// 新增商品类型
export const addGoodType = (data) => request.post('/api/vm-service/skuClass', data)

// 修改商品类型
export const updateGoodType = (data) => request.put(`/api/vm-service/skuClass/${data.classId}`, data)

// 删除商品类型
export const delGoodType = (classId) => request.delete(`/api/vm-service/skuClass/${classId}`)

// 新增商品
export const addGood = (data) => request.post('/api/vm-service/sku', data)

// 修改商品
export const updateGood = (data) => request.put(`/api/vm-service/sku/${data.skuId}`, data)

// 商品数据导入
export const importGoodData = (data) => request.post('/api/vm-service/sku/upload', data)

// 搜索策略列表
export const searchPolicyList = (params) => request.get('/api/vm-service/policy/search', { params })

// 新增策略
export const addPolicy = (data) => request.post('/api/vm-service/policy', data)

// 修改策略
export const updatePolicy = (data) => request.put(`/api/vm-service/policy/${data.policyId}`, data)

// 根据策略搜索设备
export const getVmByPolicy = (params, policyId) => request.get(`/api/vm-service/policy/vmList/${policyId}`, { params })

// 删除策略
export const delPolicy = (policyId) => request.delete(`/api/vm-service/policy/${policyId}`)
